import { channel } from "~/config/env"
// ********************************商品管理
/**
 * 接口名称： findGoodsList
 * 接口用途： 获取商品列表信息
 * isReal//1.售卖中 2售完下架 3我下架的
 * is_on_sale//1未上架
 * @param  {} app
 */
export const findGoodsList = (app, goodsName, shopPriceUp, shopPriceFloor,
  isOnSale, isReal, shopId, catId, pageNum, pageSize) => app
  .$axios.$post(`/api/${channel}/supply/goods/app1.0/findGoodsList`, {
  goodsName, shopPriceUp, shopPriceFloor, isOnSale, isReal, shopId, catId, pageNum, pageSize
})

/**
 * 接口名称： addGoods
 * 接口用途： 添加商品信息
 * @param  {} app
 */
export const addGoods = (app, goodsName,rebateCycle,goodsImg,goodsAttrList,
  goodsDesc,supplyServiceGoodsList,purchaseCategoryGoodsList,shopCategoryGoodsList) => app
  .$axios.$post(`/api/${channel}/supply/goods/app1.0/addGoods`, {
  goodsName,rebateCycle,goodsImg,goodsAttrList,goodsDesc,supplyServiceGoodsList,
  purchaseCategoryGoodsList,shopCategoryGoodsList
})



/**
 * 接口名称： deleteGoods
 * 接口用途： 删除商品服务
 * @param  {} app
 * @param  {} ids
 */
export const deleteGoods = (app, ids) => {
  let params = new URLSearchParams()
  params.append('ids', ids)
  return app.$axios.$post(`/api/${channel}/supply/goods/app1.0/deleteGoods`, params, {
    headers: {
      'Content-Type': 'application/x-www-form-urlencoded' // 'application/x-www-form-urlencoded'
    }
  })
}

/**
 * 接口名称： findGoodsOrderGoodsList
 * 接口用途： 订单商品查询
 * @param  {} app
 * @param  {} id
 */
export const findGoodsOrderGoodsList = (app, id) => app
.$axios.$get(`/api/${channel}/supply/goodsOrderGoods/app1.0/findGoodsOrderGoodsList/`, {
  params: {
    id
  }
})

/**
 * 接口名称： addGoodsOrderGoods
 * 接口用途： 订单商品添加
 * @param  {} app
 * @param  {} {recId
 * @param  {} orderId
 * @param  {} goodsId
 * @param  {} goodsName
 * @param  {} goodsNo
 * @param  {} productId
 * @param  {} goodsNumber
 * @param  {} marketPrice
 * @param  {} goodsPrice
 * @param  {} goodsAttr
 * @param  {} sendNumber
 * @param  {} isReal
 * @param  {} extensionCode
 * @param  {} parentId
 * @param  {} isGift
 * @param  {} goodsAttrId}
 */
export const addGoodsOrderGoods = (app, {
    recId,
    orderId,
    goodsId,
    goodsName,
    goodsNo,
    productId,
    goodsNumber,
    marketPrice,
    goodsPrice,
    goodsAttr,
    sendNumber,
    isReal,
    extensionCode,
    parentId,
    isGift,
    goodsAttrId
  }) => app.$axios.$post(`/api/${channel}/supply/goodsOrderGoods/app1.0/addGoodsOrderGoods`, {
  recId, orderId, goodsId, goodsName, goodsNo, productId, goodsNumber, marketPrice, goodsPrice,
  goodsAttr, sendNumber, isReal, extensionCode, parentId, isGift, goodsAttrId
})

/**
 * 接口名称： findGoodsCartList
 * 接口用途： 商品查询
 * @param  {} app
 */
export const findGoodsCartList = (app) => app
.$axios.$get(`/api/${channel}/supply/goodsCart/app1.0/findGoodsCartList`)

/**
 * 接口名称： addGoodsCart
 * 接口用途： 购物车商品添加
 * @param  {} app
 * @param  {} {userId
 * @param  {} sessionId
 * @param  {} goodsId
 * @param  {} goodsNo
 * @param  {} productId
 * @param  {} goodsName
 * @param  {} marketPrice
 * @param  {} goodsPrice
 * @param  {} goodsNumber
 * @param  {} goodsAttr
 * @param  {} isReal
 * @param  {} recordType
 * @param  {} isGift
 * @param  {} isShipping
 * @param  {} canHandsel
 * @param  {} goodsAttrId}
 */
export const addGoodsCart = (app, {
    userId,
    sessionId,
    goodsId,
    goodsNo,
    productId,
    goodsName,
    marketPrice,
    goodsPrice,
    goodsNumber,
    goodsAttr,
    isReal,
    recordType,
    isGift,
    isShipping,
    canHandsel,
    goodsAttrId
  }) => app.$axios.$post(`/api/${channel}/supply/goodsCart/app1.0/addGoodsCart`, {
  userId, sessionId, goodsId, goodsNo, productId, goodsName, marketPrice, goodsPrice, goodsNumber, goodsAttr, isReal,
  recordType, isGift, isShipping, canHandsel, goodsAttrId
})

/**
 * @param  {} app
 * @param  {} ids
 * @param  {} isOnSale
 */
export const updateIsOnSale = (app, ids, isOnSale) => app.$axios.$post(`/api/${channel}/supply/goods/app1.0/updateIsOnSale`, {
  ids, isOnSale
})


/**
 * 接口名称：	addFavourable
 * 接口用途：	添加活动信息
 * @param  {} app
 * @param  {} {actName
 * @param  {} actType
 * @param  {} startTime
 * @param  {} endTime
 * @param  {} actDesc
 * @param  {} activityUrl
 * @param  {} favourableActivityList}
 */
// transformRequest
export const addFavourable = (app, { actName, actType, startTime, endTime, actDesc, activityUrl, favourableActivityList}) => app
  .$axios
  .$post(`/api/${channel}/supply/favourable/app1.0/addFavourable`, { actName, actType, startTime, endTime, actDesc, activityUrl, favourableActivityList })

/**
 * 接口名称： findGoodsForm
 * 接口用途： 编辑商品信息
 * @param  {} app
 * @param  {} id
 */
export const findGoodsForm = (app, id) => app.$axios.$get(`/api/${channel}/supply/goods/app1.0/findGoodsForm/${id}`)

/**
 * 接口名称： updateGoods
 * 接口用途： 修改商品信息
 * @param  {} app
 * @param  {} {goodsName
 * @param  {} rebateCycle
 * @param  {} goodsImg
 * @param  {} goodsAttrList
 * @param  {} goodsDesc
 * @param  {} supplyServiceGoodsList
 * @param  {} purchaseCategoryGoodsList
 * @param  {} shopCategoryGoodsList}
 */
export const updateGoods = (app, {
  id, goodsName,rebateCycle,goodsImg,goodsAttrList,goodsDesc,supplyServiceGoodsList,
  purchaseCategoryGoodsList,shopCategoryGoodsList
}) => app.$axios.$post(`/api/${channel}/supply/goods/app1.0/updateGoods`, {
  id, goodsName,rebateCycle,goodsImg,goodsAttrList,goodsDesc,supplyServiceGoodsList,
  purchaseCategoryGoodsList,shopCategoryGoodsList
})

/**
 * 接口名称： findFavourableList
 * 接口用途： 供应端获取活动列表信息
 * @param  {} app
 * @param  {} actName
 * @param  {} actStatus
 */
export const findFavourableList = (app, actName, actStatus, pageNum, pageSize) => app.$axios.$post(`/api/${channel}/supply/favourable/app1.0/findFavourableList`, {
  actName, actStatus, pageNum, pageSize
})

/**
 * 接口名称： updateActStatus
 * 接口用途： 活动开始暂停
 * @param  {} app
 * @param  {} {id
 * @param  {} actStatus}
 */
// export const updateActStatus = (app, {id, actStatus}) => {
//   let params = new URLSearchParams()
//   params.append('maps', {id, actStatus})
//   return app.$axios.$post(`/api/${channel}/supply/favourable/app1.0/updateActStatus`, params, {
//     headers: {
//       'Content-Type': 'application/x-www-form-urlencoded' // 'application/x-www-form-urlencoded'
//     }
//   })
// }
export const updateActStatus = (app, {id, actStatus}) => app
  .$axios.$post(`/api/${channel}/supply/favourable/app1.0/updateActStatus`, {
    id,
    actStatus
  })

/**
 * 接口名称： deleteFavourableById
 * 接口用途： 删除活动
 * @param  {} app
 * @param  {} id
 */
export const deleteFavourableById = (app, id) => app.$axios.$post(`/api/${channel}/supply/favourable/app1.0/deleteFavourableById/${id}`)

/**
 * 接口名称： findFavourableForm
 * 接口用途： 编辑 / 查看活动信息
 * @param  {} app
 * @param  {} id
 */
export const findFavourableForm = (app, id) => app.$axios.$get(`/api/${channel}/supply/favourable/app1.0/findFavourableForm/${id}`)

/**
 * 接口名称： updateFavourable
 * 接口用途： 修改活动信息
 * @param  {} app
 * @param  {} {id
 * @param  {} actName
 * @param  {} actType
 * @param  {} startTime
 * @param  {} endTime
 * @param  {} actDesc
 * @param  {} activityUrl
 * @param  {} favourableActivityList}
 */
export const updateFavourable = (app, {id, actName, actType, startTime, endTime, actDesc, activityUrl, favourableActivityList}) => app
.$axios.$post(`/api/${channel}/supply/favourable/app1.0/updateFavourable`, {
  id,
  actName,
  actType,
  startTime,
  endTime,
  actDesc,
  activityUrl,
  favourableActivityList
})
